package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:实例内部类
 * User: 阿宾
 * Date: 2024-06-13
 * Time: 15:30
 */
class OuterClass{
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    public int data4 = 28;

    class InnerClass{
        public int data4 = 5;
        public static final int data5 = 6;
        public static int data6 = 6;

        public void test(){
            System.out.println(data4);//5
            System.out.println(this.data4);//5
            System.out.println(OuterClass.this.data4);//28
            System.out.println("内部类的test()方法");
        }

    }
    public void test(){
        System.out.println("外部类的test()方法");
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data6);
    }
}
public class Test03{
    public static void main(String[] args) {
        /*OuterClass outerClass = new OuterClass();
//        System.out.println(outerClass.data1);
        outerClass.test();*/

        OuterClass outerClass1 = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass1.new InnerClass();
        /*System.out.println(innerClass.data4);*/
        innerClass.test();

    }
}
